@extends("admin.common.admin")
    <title>用户管理</title>
@section("cnt")
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
        首页
    <span class="c-gray en">&gt;</span>
        房源管理
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">
    @include("admin.common.msg")
    <form action="{{ route("admin.admin.user") }}" method="get">
        <div class="text-c"> 日期范围：
            <input type="text" value="{{ request()->get("datemax") }}" name="datemax" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" style="width:120px;">
            -
            <input type="text" value="{{ request()->get("datemin") }}" name="datemin" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:120px;">
            <input type="text" value="{{ request()->get("username") }}" class="input-text" style="width:250px" placeholder="输入会员名称、电话、邮箱" id="" name="username">
            <button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
        </div>
    </form>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            {!! $fang->addBtn("admin.fang.create","添加用户") !!}
        </span>
        <span class="r">共有数据：
        </span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="80">ID</th>
                <th width="100">房源名称</th>
                <th width="40">小区地址</th>
                <th width="90">租赁方式</th>
                <th width="150">房源业主</th>
                <th width="">房源租金</th>
                <th width="130">是否推荐</th>
                <th width="70">配套设施</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach($data as $item)
            <tr class="text-c">
                <td>{{ $item->id  }}</td>
                <td>{{ $item->fang_name }}</td>
                <td>{{ $item->getAreaToName() }}-{{ $item->fang_addr }}</td>
                <td>{{ $item->getAttrIdToName($item->fang_rent_class) }}</td>
                <td>{{ $item->owner->name }}</td>
                <td>{{ $item->fang_rent }}</td>
                <td>{!! $item->recommend !!}</td>
                <td>{{ $item->getAttrIdToName($item->fang_config) }}</td>
                <td class="td-manage">
                    {!! $fang->editBtn("admin.fang.edit","修改",["id" => $item->id]) !!}
                    {!! $fang->deleteBtn("admin.fang.destroy","删除",["id" => $item->id]) !!}
                </td>
            </tr>
            @endforeach
            </tbody>
        </table>
        {{ $data->appends(request()->except("page"))->links() }}
    </div>
</div>
@endsection
@section("js")
<script>
    $(function () {
        $(".del").click(function () {
            // let href = ;
            layer.confirm('确认删除该用户吗？', {
                btn: ['确认','取消'] //按钮
            }, ()=>{
                $.ajax({
                    url : $(this).attr("href"),
                    type : "delete",
                    data :{
                        _token:"{{ csrf_token() }}"
                    }
                }).then(ret => {
                    // console.log(ret);
                    layer.msg(ret.msg, {icon: 1,time: 2000},()=>{
                        if(ret.status == 200){
                            $(this).parents("tr").remove();
                        }

                    });
                });

            });


            return false;
        });
    })

</script>
@endsection
